//
//  OrderDetailViewController.m
//  ShoppingExperience
//
//  Created by LiYinDi on 15/9/25.
//  Copyright (c) 2015年 RuiBen. All rights reserved.
//

#import "OrderDetailViewController.h"

#import "CommonDetailTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "PrintWebViewController.h"
@interface OrderDetailViewController ()//<PrintWebDelegate>
{
    NSMutableArray *itemCodeArray;
    NSMutableArray *itemNameArray;
    NSMutableArray *lineTotalArray;
    NSMutableArray *gramArray;
    NSMutableArray *whsNameArray;
    NSMutableArray *urlArray;
    
    PrintWebViewController *printWebVC;
    NSString *docStatusStr;
}
@end

@implementation OrderDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if (printWebVC.view!=nil) {
        [printWebVC.view removeFromSuperview];
        [printWebVC removeFromParentViewController];
        
    }

    itemCodeArray=[NSMutableArray array];
     itemNameArray=[NSMutableArray array];
    lineTotalArray=[NSMutableArray array];
    gramArray=[NSMutableArray array];
    whsNameArray=[NSMutableArray array];
     urlArray=[NSMutableArray array];
    
    [_alphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    [_alphaView addTarget:self action:@selector(alphaViewClick) forControlEvents:UIControlEventTouchUpInside];
    
    [_relatedBtn addTarget:self action:@selector(relatedBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self requestOrderDetail:_docNumStr];

    // Do any additional setup after loading the view from its nib.
}
-(void)relatedBtnClick
{
    if (_relatedDocNumLabel.text.length>0) {
        
   
    if ([self.delegate respondsToSelector:@selector(RelateDepositBtnClick)]) {
        [self.delegate RelateDepositBtnClick];
    }
    }
    else
    {
        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"未关联定金单" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
    }
}
-(IBAction)printBtnClick:(id)sender
{
    if (printWebVC.view!=nil) {
        [printWebVC.view removeFromSuperview];
        [printWebVC removeFromParentViewController];
        
    }
    printWebVC=[[PrintWebViewController alloc] init];
   // printWebVC.delegate=self;
    printWebVC.docNumStr=_docNumStr;
    printWebVC.docTypeStr=@"Order";
    if ([docStatusStr isEqualToString:@"已结算"]) {
        printWebVC.docStatusStr=@"Y";
    }
    else if ([docStatusStr isEqualToString:@"未收银"]){
        printWebVC.docStatusStr=@"N";
    }
    else{
        printWebVC.docStatusStr=@"";
    }
   // printWebVC.docStatusStr=docStatusStr;
    printWebVC.view.frame = CGRectMake(0,
                                          0,
                                          self.view.bounds.size.width,
                                          self.view.bounds.size.height);
    
    [self addChildViewController:printWebVC];
    [self.view addSubview:printWebVC.view];
    

}
//-(void)PrintWebBackClick
//{
//    if (printWebVC.view!=nil) {
//        [printWebVC.view removeFromSuperview];
//        [printWebVC removeFromParentViewController];
//        
//    }
//}
-(IBAction)cancelOrderBtnClick:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(CancelOrderBtnClick)]) {
        [self.delegate CancelOrderBtnClick];
    }
}
-(void)alphaViewClick
{
    if (self.view!=nil) {
        [self.view removeFromSuperview];
        [self removeFromParentViewController];
        
    }


}
-(void)requestOrderDetail:(NSString *)codeStr
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [params setObject:@"Order" forKey:@"DocType"];
        [params setObject:codeStr forKey:@"DocNum"];
        // NSLog(@"paramsLIST====%@",params);
        [HttpRequest requestData:@"Guide/OrderDetail" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
//             NSLog(@"detaillll=%@",severDataDict.dataDict);
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    _cancelOrderBtn.hidden=NO;
                    _printBtn.hidden=NO;
                    _detailNumLabel.text=[severDataDict.dataDict objectForKey:@"DocNum"];
                  
                    [Global resizeForLable:_detailNumLabel WithText:_detailNumLabel.text parentView:self.view];
                    NSString *statusStr=[severDataDict.dataDict objectForKey:@"DocStatus"];
                    docStatusStr=statusStr;
                    _detailStatusLabel.text=[NSString stringWithFormat:@"【%@】",statusStr];
                    if ([statusStr isEqualToString:@"未收银"]) {
                         _printBtn.hidden=NO;
                        [_detailStatusLabel setTextColor:[Global parseStatusColor:statusStr]];
                    }
                    else if ([statusStr isEqualToString:@"已取消"])
                    {
                        _cancelOrderBtn.hidden=YES;
                        _printBtn.hidden=YES;
                        [_detailStatusLabel setTextColor:[Global parseStatusColor:statusStr]];
                        
                    }
                    else if ([statusStr isEqualToString:@"已收定金"])
                    {
                        _printBtn.hidden=YES;
                        [_detailStatusLabel setTextColor:[Global parseStatusColor:statusStr]];
                        
                        
                    }
                    else if ([statusStr isEqualToString:@"已结算"])
                    {
                        _cancelOrderBtn.hidden=YES;
                        _printBtn.hidden=NO;
                        [_detailStatusLabel setTextColor:[Global parseStatusColor:statusStr]];
                        
                    }
                    
                  //  [self resizeLabel:_detailStatusLabel];
                    [Global resizeForLable:_detailStatusLabel WithText:_detailStatusLabel.text parentView:self.view];
            
                    CGRect statusframe=_detailStatusLabel.frame;
                    statusframe.origin.x=_detailNumLabel.frame.origin.x+_detailNumLabel.frame.size.width;
                    _detailStatusLabel.frame=statusframe;
                    
                  
                    if ([[severDataDict.dataDict objectForKey:@"MemberName"] length]!=0) {
                        _detailMemberNameLabel.text=[severDataDict.dataDict objectForKey:@"MemberName"];
                    }
                    else
                    {
                        _detailMemberNameLabel.text=@"未填写";
                    }
                    if ([severDataDict.dataDict objectForKey:@"GuideName"]!=[NSNull null]) {
                        _detailGuideNameLabel.text=[severDataDict.dataDict objectForKey:@"GuideName"];
                    }
                 //   [self resizeLabel:_detailMemberNameLabel];
                  //  [self resizeLabel:_detailGuideNameLabel];
                    [Global resizeForLable:_detailMemberNameLabel WithText:_detailMemberNameLabel.text parentView:self.view];
                     [Global resizeForLable:_detailGuideNameLabel WithText:_detailGuideNameLabel.text parentView:self.view];
                    CGRect frame=_detailGuideNameTagLabel.frame;
                    frame.origin.x=_detailMemberNameLabel.frame.origin.x+_detailMemberNameLabel.frame.size.width+15;
                    _detailGuideNameTagLabel.frame=frame;
                    
                    CGRect frame1=_detailGuideNameLabel.frame;
                    frame1.origin.x=_detailGuideNameTagLabel.frame.origin.x+_detailGuideNameTagLabel.frame.size.width+3;
                    _detailGuideNameLabel.frame=frame1;
                    
                    CGRect frame2=_detailStoreNameTagLabel.frame;
                    frame2.origin.x=_detailGuideNameLabel.frame.origin.x+_detailGuideNameLabel.frame.size.width+15;
                    _detailStoreNameTagLabel.frame=frame2;
                    
                    CGRect frame3=_detailStoreNameLabel.frame;
                    frame3.origin.x=_detailStoreNameTagLabel.frame.origin.x+_detailStoreNameTagLabel.frame.size.width+3;
                    _detailStoreNameLabel.frame=frame3;
                    
                    
                    
                    if ([severDataDict.dataDict objectForKey:@"StoreName"]!=[NSNull null]) {
                        _detailStoreNameLabel.text=[severDataDict.dataDict objectForKey:@"StoreName"];
                    }
                    if ([severDataDict.dataDict objectForKey:@"DocDate"]!=[NSNull null]) {
                        _detailDateLabel.text=[severDataDict.dataDict objectForKey:@"DocDate"];
                    }
                    
                    if ([severDataDict.dataDict objectForKey:@"Remark"]!=[NSNull null]) {
                        _detailTextView.text=[severDataDict.dataDict objectForKey:@"Remark"];
                        //NSLog(@"_detailTextView.text=%@",_detailTextView.text);
                        CGFloat height=  [Global heightForTextView:_detailTextView WithText:_detailTextView.text];
                        
                        CGRect frameA=_detailTextView.frame;
                        frameA.size.height=height;
                        _detailTextView.frame=frameA;

                        CGRect frameD=_cancelOrderRecordView.frame;
                        frameD.origin.y=_detailTextView.frame.origin.y+_detailTextView.frame.size.height+10;
                        _cancelOrderRecordView.frame=frameD;
                        
                        
                        CGRect frameE=_detailLastView.frame;
                        frameE.size.height=_cancelOrderRecordView.frame.origin.y+_cancelOrderRecordView.frame.size.height+2;
                        _detailLastView.frame=frameE;

                    }
                     NSString *dateStr=[severDataDict.dataDict objectForKey:@"DueDate"];
                    _cashierDateLabel.text=dateStr;
                   
                  //  [self resizeLabel:_cashierDateLabel];
                     [Global resizeForLable:_cashierDateLabel WithText:_cashierDateLabel.text parentView:self.view];
                    if (dateStr.length>0) {
                        CGRect framea=_cashierTagLabel.frame;
                        framea.origin.x=_cashierDateLabel.frame.origin.x+_cashierDateLabel.frame.size.width+10;
                        _cashierTagLabel.frame=framea;
                        
                      

                    }
                    else
                    {
                        CGRect framea=_cashierTagLabel.frame;
                        framea.origin.x=_cashierDateLabel.frame.origin.x+_cashierDateLabel.frame.size.width;
                        _cashierTagLabel.frame=framea;

                    }
                    CGRect frameb=_cashierLabel.frame;
                    frameb.origin.x=_cashierTagLabel.frame.origin.x+_cashierTagLabel.frame.size.width+2;
                    _cashierLabel.frame=frameb;
                    
                    NSString *cashierStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"Cash"] floatValue]];
                    _cashierLabel.text=cashierStr;
                  //  [self resizeLabel:_cashierLabel];
                      [Global resizeForLable:_cashierLabel WithText:_cashierLabel.text parentView:self.view];
                    
                    
                     NSString *bankStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"UnionPay"] floatValue]];
                    _bankLabel.text=bankStr;
                    
                    CGRect frame4=_bankTagLabel.frame;
                    frame4.origin.x=_cashierLabel.frame.origin.x+_cashierLabel.frame.size.width+12;
                    _bankTagLabel.frame=frame4;
                    
                    CGRect frame5=_bankLabel.frame;
                    frame5.origin.x=_bankTagLabel.frame.origin.x+_bankTagLabel.frame.size.width+3;
                    _bankLabel.frame=frame5;
                    
                    
                    NSString *depositStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"Subscription"] floatValue]];
                    _depositLabel.text=depositStr;
                    //[self resizeLabel:_depositLabel];
                     [Global resizeForLable:_depositLabel WithText:_depositLabel.text parentView:self.view];
                    
                    NSString *integralStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"IntegralAmount"] floatValue]];
                    _integralLabel.text=integralStr;
                   // [self resizeLabel:_integralLabel];
                    [Global resizeForLable:_integralLabel WithText:_integralLabel.text parentView:self.view];
                    
                    NSString *decutibleStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"Rebate"] floatValue]];
                    _decutibleLabel.text=decutibleStr;
                   // [self resizeLabel:_decutibleLabel];
                     [Global resizeForLable:_decutibleLabel WithText:_decutibleLabel.text parentView:self.view];

                    NSString *oldStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"OldMaterial"] floatValue]];
                    _oldMeterialLabel.text=oldStr;
                   // [self resizeLabel:_oldMeterialLabel];
                     [Global resizeForLable:_oldMeterialLabel WithText:_oldMeterialLabel.text parentView:self.view];
                    
                    CGRect frame6=_integralTagLabel.frame;
                    frame6.origin.x=_depositLabel.frame.origin.x+_depositLabel.frame.size.width+12;
                    _integralTagLabel.frame=frame6;
                    
                    CGRect frame7=_integralLabel.frame;
                    frame7.origin.x=_integralTagLabel.frame.origin.x+_integralTagLabel.frame.size.width+3;
                    _integralLabel.frame=frame7;
                    
                    CGRect frame8=_decutibleTagLabel.frame;
                    frame8.origin.x=_integralLabel.frame.origin.x+_integralLabel.frame.size.width+12;
                    _decutibleTagLabel.frame=frame8;
                    
                    CGRect frame9=_decutibleLabel.frame;
                    frame9.origin.x=_decutibleTagLabel.frame.origin.x+_decutibleTagLabel.frame.size.width+3;
                    _decutibleLabel.frame=frame9;
                    
                    CGRect frame10=_oldMeterialTagLabel.frame;
                    frame10.origin.x=_decutibleLabel.frame.origin.x+_decutibleLabel.frame.size.width+12;
                    _oldMeterialTagLabel.frame=frame10;
                    
                    CGRect frame11=_oldMeterialLabel.frame;
                    frame11.origin.x=_oldMeterialTagLabel.frame.origin.x+_oldMeterialTagLabel.frame.size.width+3;
                    _oldMeterialLabel.frame=frame11;

                   NSString *relateNumStr=[severDataDict.dataDict objectForKey:@"DepositNum"];
                   // NSLog(@"relateNumStr===%@",relateNumStr);
                    if (relateNumStr.length>0) {
                    NSString *relateDateStr=[severDataDict.dataDict objectForKey:@"RelationDate"] ;
                    _relateDepositView.hidden=NO;
                    _relateDateLabel.text=relateDateStr;
                    [Global resizeForLable:_relateDateLabel WithText:_relateDateLabel.text parentView:_detailScrollView];
                    CGRect frameA=_relateDocNumTagLabel.frame;
                    frameA.origin.x=_relateDateLabel.frame.origin.x+_relateDateLabel.frame.size.width+10;
                    _relateDocNumTagLabel.frame=frameA;
                        
                    CGRect frameB=_relatedDocNumLabel.frame;
                    frameB.origin.x=_relateDocNumTagLabel.frame.origin.x+_relateDocNumTagLabel.frame.size.width+3;
                    _relatedDocNumLabel.frame=frameB;
                    
                    _relatedDocNumLabel.text=relateNumStr;
                        CGRect framea=_shopInfoView.frame;
                        framea.origin.y=_relateDepositView.frame.origin.y+_relateDepositView.frame.size.height+1;
                        _shopInfoView.frame=framea;
                       
                        
                    }
                    else
                    {
                        _relateDepositView.hidden=YES;
                        
                       
                        CGRect framea=_shopInfoView.frame;
                        framea.origin.y=_referLineLabel.frame.origin.y+_referLineLabel.frame.size.height+1;
                        _shopInfoView.frame=framea;

                    }
                    CGRect framee=_detailTableView.frame;
                    framee.origin.y=_shopInfoView.frame.origin.y+_shopInfoView.frame.size.height+1;
                    _detailTableView.frame=framee;

                    if ([severDataDict.dataDict objectForKey:@"Number"]!=[NSNull null]&&[severDataDict.dataDict objectForKey:@"GramTotal"]!=[NSNull null]) {
                        NSString *numStr=[NSString stringWithFormat:@"%d",[[severDataDict.dataDict objectForKey:@"Number"] integerValue]];
                        NSString *gramTotalStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"GramTotal"] floatValue]];
                        
                        _shopInfoLabel.text=[NSString stringWithFormat:@"(共%@件，%@g)",numStr,gramTotalStr];
                    }
//
                    
                    NSMutableArray *mDataLineArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"] ];
                    for (int i=0; i<mDataLineArray.count; i++) {
                        [whsNameArray addObject:[[mDataLineArray objectAtIndex:i] objectForKey:@"WhsName"]];
                        [itemNameArray addObject:[[mDataLineArray objectAtIndex:i] objectForKey:@"ItemName"]];
                        [itemCodeArray addObject:[[mDataLineArray objectAtIndex:i] objectForKey:@"ItemCode"]];
                        [urlArray addObject:[[mDataLineArray objectAtIndex:i] objectForKey:@"ImageUrl"]];
                        [gramArray addObject:[[mDataLineArray objectAtIndex:i] objectForKey:@"Gram"]];
                        [lineTotalArray addObject:[[mDataLineArray objectAtIndex:i] objectForKey:@"LineTotal"]];
                        //[orderDetailAttributeArray addObject:[[mDataLineArray objectAtIndex:i] objectForKey:@"Attributes"]];
                    }

                    [_detailTableView reloadData];
                    CGRect frameD=_detailTableView.frame;
                    frameD.size.height=120*mDataLineArray.count;
                    _detailTableView.frame=frameD;
//
                    CGRect frameL=_detailLastView.frame;
                    frameL.origin.y=_detailTableView.frame.origin.y+_detailTableView.frame.size.height+15;
                    _detailLastView.frame=frameL;
//
                    [_detailScrollView setContentSize:CGSizeMake(0, _detailLastView.frame.origin.y+ _detailLastView.frame.size.height)];
                    [_detailScrollView setScrollEnabled:YES];
                    
                    NSString *cancelDateStr=[severDataDict.dataDict objectForKey:@"CancelDate"];
                    if (cancelDateStr.length >0) {
                        _cancelOrderDateLabel.text=cancelDateStr;
                        [Global resizeForLable:_cancelOrderDateLabel WithText:_cancelOrderDateLabel.text parentView:self.view];
                        
                        CGRect frameA=_cancelOrderGuideNameTagLabel.frame;
                        frameA.origin.x=_cancelOrderDateLabel.frame.origin.x+_cancelOrderDateLabel.frame.size.width+12;
                        _cancelOrderGuideNameTagLabel.frame=frameA;
                        
                        CGRect frameB=_cancelOrderGuideNameLabel.frame;
                        frameB.origin.x=_cancelOrderGuideNameTagLabel.frame.origin.x+_cancelOrderGuideNameTagLabel.frame.size.width+3;
                        _cancelOrderGuideNameLabel.frame=frameB;
                        
                        _cancelOrderRecordView.hidden=NO;
                        NSString *cancelGuideStr=[severDataDict.dataDict objectForKey:@"CancelBy"];
                        _cancelOrderGuideNameLabel.text=cancelGuideStr;
                     //   [self resizeLabel:_cancelOrderGuideNameLabel];
                         [Global resizeForLable:_cancelOrderGuideNameLabel WithText:_cancelOrderGuideNameLabel.text parentView:self.view];
                        
                        CGRect frame1=_cancelDepositTagLabel.frame;
                        frame1.origin.x=_cancelOrderGuideNameLabel.frame.origin.x+_cancelOrderGuideNameLabel.frame.size.width+12;
                        _cancelDepositTagLabel.frame=frame1;
                        
                        CGRect frameC=_cancelDepositLabel.frame;
                        frameC.origin.x=_cancelDepositTagLabel.frame.origin.x+_cancelDepositTagLabel.frame.size.width+3;
                        _cancelDepositLabel.frame=frameC;
                        
                        
                        NSString *RSubscriptionStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"RSubscription"] floatValue]];
                        _cancelDepositLabel.text=RSubscriptionStr;
                        
                        NSString *CancelRemarkStr=[severDataDict.dataDict objectForKey:@"CancelRemark"];
                        _cancelRemarkLabel.text=CancelRemarkStr;
                    }
                    else
                    {
                        _cancelOrderRecordView.hidden=YES;
                    }
                    

                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
//                        if (_timer!=nil) {
//                            [_timer invalidate];
//                            _timer=nil;
//                        }
                        [Global loginViewController:self noteStr:requestResultStr];
                        //    [Global loginViewController:self];
                    }
                    
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
   
    return itemCodeArray.count;
   
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 120;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
        static NSString * const  OrderDetailIdentifier = @"OrderDetailIdentifier";
        CommonDetailTableViewCell *cell=( CommonDetailTableViewCell *)[tableView dequeueReusableCellWithIdentifier: OrderDetailIdentifier];
        if (cell==nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"CommonDetailTableViewCell" owner:self options:nil];
            cell = [array objectAtIndex:0];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        //        cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame] ;
        //        cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:250.0f/255.0f green:250.0f/255.0f blue:250.0f/255.0f alpha:1.0f];
        if (itemNameArray.count>0) {
            cell.productNameLabel.text=[NSString stringWithFormat:@"%@ %@",[itemCodeArray objectAtIndex:indexPath.row],[itemNameArray objectAtIndex:indexPath.row]];
        }
        if (whsNameArray.count>0) {
            cell.stockAddressLabel.text=[whsNameArray objectAtIndex:indexPath.row];
        }
    
        if (urlArray.count>0) {
            if ([[urlArray objectAtIndex:indexPath.row] length]>0) {
                
                [cell.productImageView setImageWithURL:[NSURL URLWithString:[urlArray objectAtIndex:indexPath.row]]];
            }
        }
      if (gramArray.count>0) {
        
        cell.weightLabel.text=[NSString stringWithFormat:@"%0.02fg",[[gramArray objectAtIndex:indexPath.row] floatValue]];
          cell.weightLabel.numberOfLines = 0;
          cell.weightLabel.lineBreakMode = NSLineBreakByWordWrapping;
          CGSize maximumLabelSize = CGSizeMake(1000, cell.weightLabel.frame.size.height);
          
          CGSize expectSize = [cell.weightLabel sizeThatFits:maximumLabelSize];
          CGRect frame1 = CGRectMake(cell.weightLabel.frame.origin.x, cell.weightLabel.frame.origin.y,expectSize.width, cell.weightLabel.frame.size.height );
          cell.weightLabel.frame=frame1;

          
          CGRect frame2= cell.priceLabel.frame;
          frame2.origin.x=cell.weightLabel.frame.origin.x+cell.weightLabel.frame.size.width+30;
          cell.priceLabel.frame=frame2;

      }

        if (lineTotalArray.count>0) {
            float AvgPrice=[[lineTotalArray objectAtIndex:indexPath.row] floatValue];
            NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];
            
            cell.priceLabel.text=[NSString stringWithFormat:@"¥%@",AvgPriceStr];
        }
        return cell;
        
    
    
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
        if ([self.delegate respondsToSelector:@selector(productItemDetail:)]) {
            [self.delegate productItemDetail:[itemCodeArray objectAtIndex:indexPath.row]];
        }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
